package com.adapters;

import com.Gourmet.Activities.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class AddImgAdp extends BaseAdapter{

	int GalItemBg;
    private Context cont;
	private Integer[] ImagenId;

    public AddImgAdp(Context c, Integer[] ImagenId) {
        cont = c;
        this.ImagenId = ImagenId;
        TypedArray typArray = c.obtainStyledAttributes(R.styleable.GalleryTheme);
        GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
        typArray.recycle();
    }

    public int getCount() {
    	return ImagenId.length;
    }

    public Object getItem(int position) {
        return position; 
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imgView = new ImageView(cont);
        imgView.setImageResource(ImagenId[position]);
        imgView.setLayoutParams(new Gallery.LayoutParams(80, 70));
        imgView.setScaleType(ImageView.ScaleType.FIT_XY);
        imgView.setBackgroundResource(GalItemBg);

        return imgView;
    }

}
